<template>
    <el-container class="mev-div-border">
        <el-header>
            <el-row>
                <el-col :span="16" style="text-align: left">
                    卫星仿真
                </el-col>
                <el-col :span="8" style="position:absolute;top:-6px;right:0px;text-align: right">
                    <el-button @click="toolbarFunc('close')"><p style="position: absolute;right: 13px;top: 15px">关闭</p></el-button>
                </el-col>
            </el-row>
        </el-header>
        <el-main class="mev-div-border">
            <el-row>
                <el-col>
                    <el-button @click="start1">加载数据</el-button>
                </el-col>
                <el-col>
                    <el-button @click="clearAll">清空</el-button>
                </el-col>
            </el-row>
        </el-main>
    </el-container>
</template>

<script>
import Environment from "../../../plugins/utils/environment.js";
/*import "../../../plugins/mev/TheSatellite1/SatellitePassEffect";*/
import loadJson from "../../../plugins/utils/loadJson";
/*import SatellitePassEffect1 from "@/plugins/mev/TheSatellite1/satelliteTransit"*/
import satelliteTransit from "@/plugins/mev/TheSatellite1/satelliteTransit";
let wx = null;
let wxobj = null;
export default {
    name: "TheSatelliteSimulation",

    data() {
        return {
            Sate: null
        };
    },
    beforeDestroy() {
        this.clearAll();
        window.cesiumViewer.animation.container.style.display = "none";
        window.cesiumViewer.timeline.container.style.display = "none";
    },
    mounted() {
        window.cesiumViewer.animation.container.style.display = "block";
        window.cesiumViewer.timeline.container.style.display = "block";
        let opt = {
            viewer: window.cesiumViewer
        };
        this.Sate = new satelliteTransit(window.cesiumViewer);
    },
    methods: {
        toolbarFunc: function(method) {
            switch (method) {
                case "close": {
                    if (this.$route.name !== "EmptyComponent") {
                        this.$router.push({ name: "EmptyComponent" });
                    }
                    break;
                }

                default:
                    break;
            }
        },
        start1: function() {
            this.Sate.initST();
        },
        /*   start1: function() {
            window.cesiumViewer.animation.container.style.display = "block";
            window.cesiumViewer.timeline.container.style.display = "block";
            let that = this;
            loadJson(Environment.getDataBasePath() + "/file/simple.czml", function(wx) {
                //that.$viewer.dataSources.add(wx);
                wxobj = Cesium.CzmlDataSource.load(wx);
                that.$viewer.dataSources.add(wxobj);
                //viewer.camera.flyHome(0);
                that.$viewer.camera.flyHome(0);
            });
        },*/

        stop: function() {},
        clearAll: function() {
            let len = window.cesiumViewer.dataSources.length;
            if (len > 0) {
                for (let i = 0; i < len; i++) {
                    let dataSource = window.cesiumViewer.dataSources.get(i);
                    if (dataSource._name === "simple") {
                        window.cesiumViewer.dataSources.remove(dataSource);
                    }
                }
            }
            this.Sate.removeST();
        },

        ceShi: function() {}
    }
};
</script>

<style scoped>
.el-container {
    color: #ffffff;
}

.el-header {
    line-height: 60px;
}

.el-main {
    margin: 10px;
    padding: 10px;
}

.el-button {
    margin-top: 5px;
    width: 100%;
}
</style>
